// initial state
const state = () => ({
  isCollapse: false,// 菜单展开关闭
  title: '麦兜',// 标题
  copyright: '麦兜 - copyright',// 版权
  routers: [],// 路由信息
  currentRoute: []// 面包屑title标题
})

// getters
const getters = {}

// actions
const actions = {
  // 响应是否关闭开启菜单
  changeCollapse({commit}) {
    commit('SET_COLLAPSE')
  },
  /**
   * 设置路由
   * @param commit
   * @param data
   */
  setRouters({commit}, data) {
    commit('SET_ROUTERS', data)
  },
  /**
   * 设置herder title
   * @param commit
   * @param data
   */
  setCurrentRoute({commit}, data) {
    commit('SET_CRUMBS_TITLE', data)
  }
}

// mutations
const mutations = {
  // 设置菜单是否展示
  SET_COLLAPSE: (state) => {
    state.isCollapse = !state.isCollapse
  },
  // 设置路由
  SET_ROUTERS: (state, data) => {
    state.routers = data
  },
  // 设置herder title
  SET_CRUMBS_TITLE: (state, data) => {
    state.currentRoute = data
  }
}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations
}